package com.gxa.web_admin.rabbitmq;

import com.gxa.web_admin.SpringBootApplicationTimoProjectStart;


import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;


@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootApplicationTimoProjectStart.class)
public class SpringAmqpPublisherTest {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void sendMessage(){
        // 3.声明队列,需要提前在RabbitMQ手动创建好
        final  String QUEUE_NAME = "gxa.queue";
        String message = "使用AMQP发送消息";
        rabbitTemplate.convertAndSend(QUEUE_NAME,message);
        System.out.println("发送消息成功："+message);
    }



}
